home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga News 96
/
Amiga News 96.iso
/
amig_ad_os
/
avm
/
avminstall
/
rexx
/
silentanswer.avm
< prev
next >
Wrap
Text File
|
1977-12-31
|
12KB
|
493 lines
/* TITLE: avm:rexx/silentanswer.avm */
/* we want results! Otherwise, we wouldn't get anything from RESULT */
options results
/* Need to make sure that stdtail.avm is also included */
signal on halt
signal on novalue
signal on syntax
signal on break_c
/* needed for some of the functions we use */
call addlib("rexxsupport.library", 0, -30, 0)
/* a higher than normal priority since calls are important to us :) */
call pragma('priority', 1)
/* ensure that commands are directed to the correct server */
parse arg servername .
address value servername
parse arg servername faxscript datascript distinctivering 'CID$' acidname '$' acidnumber '$'
call setclip(address() || 'CIDNAME', acidname)
call setclip(address() || 'CIDNUMBER', acidnumber)
/* Initialize log entry */
handle = makeUniqueFile()
call initLogEntry()
log.type = 'Silent'
mailbox = 'silent'
/* Put beep in here if you want */
readkeyagain:
'readnkeys' '1' '90'
a_=rc
if a_=0 then value=result
if 0 then nop
else if a_=0 then signal possiblechoice
else if a_=4 then signal stdfax
else if a_=5 then signal stddata
else if a_=12 then signal stdabort
else if a_=14 then signal stderror
else if a_=16 then signal stderror
/* Put another beep in here if you want */
finished:
/* Save log entry */
log.comment = ''
log.origMailbox = mailbox
call saveLogEntry(mailbox, handle)
exit
possiblechoice:
select
when value = '2' then signal stdfax
when value = '1' then signal dorecord
when value = '5' then signal stddata
when value = '*' then signal stdabort
otherwise nop
end
signal finished
dorecord:
call time('r')
'recordvoice' '120' '-1' '-1' handle
a_=rc
if 0 then nop
else if a_=4 then signal stdfax
else if a_=5 then signal stddata
else if a_=12 then signal stdabort
else if a_=14 then signal stderror
else if a_=16 then signal stderror
log.type = 'Voice'
log.length = trunc(time('e'))
log.filename = handle
signal finished
/* TITLE: avm:rexx/simplestdtail.avm */
/* This is the standard tail */
exit
exit
mailboxDir: procedure
parse arg mailbox
return 'avmmbox:' || mailbox || '/'
logFile: procedure
parse arg mailbox, magiccookie
return 'avmmbox:' || mailbox || '/logs/' || magiccookie
voiceFile: procedure
parse arg mailbox, magiccookie
if (verify(magiccookie, '/:', 'M') = 0) then
return 'avmmbox:' || mailbox || '/voices/' || magiccookie
else
return magiccookie
makeUniqueFile: procedure
if arg() ~= 0 then do
rc = "makeUniqueFile: bad args"
signal error
end
return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
convertToDate: procedure
if arg() ~= 1 then do
rc = "convertToDate: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
actualDate = (timeInC - actualTime - 2922*86400) % 86400
return actualDate /* returning it in 'internal' format */
convertToTime: procedure
if arg() ~= 1 then do
rc = "convertToTime: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
return actualTime
cTime: procedure
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
return (date('i')+2922)*86400 + time('s')
/* this returns a handle that you must use after initializing log. */
initLogEntry: procedure expose log.
if arg() ~= 0 then do
rc = "initLogEntry: bad args"
signal error
end
drop log.
log. = ''
acidname = getclip(address() || 'CIDNAME')
acidnumber = getclip(address() || 'CIDNUMBER')
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
log.time = (date('i')+2922)*86400 + time('s')
log.cidname = acidname
log.cidnumber = acidnumber
return
loadLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "loadLogEntry: bad args"
signal error
end
parse arg mailbox, handle
drop log.
log. = ''
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'r')
if opened then do
call showDebugger('Loading entry' logFile(mailbox, handle))
do while ~eof(handle)
line = readln(handle)
parse upper var line variable '=' value
log.variable = value
end
call close(handle)
end; else call showDebugger('Could not load' logFile(mailbox, handle))
return
/* pass a handle here */
saveLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "saveLogEntry: bad args"
signal error
end
parse arg mailbox, handle
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'w')
if opened then do
call showDebugger('Saving entry' logFile(mailbox, handle))
call writeln(handle, 'TYPE=' || log.type)
call writeln(handle, 'TIME=' || log.time)
call writeln(handle, 'LENGTH=' || log.length)
call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
call writeln(handle, 'CIDNAME=' || log.cidname)
call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
call writeln(handle, 'COMMENT=' || log.comment)
call writeln(handle, 'FILENAME=' || log.filename)
call writeln(handle, 'ALTFILENAME=' || log.altfilename)
call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
call writeln(handle, 'RETURNRETRY=' || log.returnretry)
call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
call close(handle)
address rexx 'broadcast' 'addtomailbox' mailbox handle
end; else call showDebugger('Could not save' logFile(mailbox, handle))
return
/* pass a handle here */
updateLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "updateLogEntry: bad args"
signal error
end
parse arg mailbox, handle
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
if ~exists(logFile(mailbox, handle)) then do
call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
return
end
opened = open(handle, logFile(mailbox, handle), 'w')
if opened then do
call showDebugger('Updating entry' logFile(mailbox, handle))
call writeln(handle, 'TYPE=' || log.type)
call writeln(handle, 'TIME=' || log.time)
call writeln(handle, 'LENGTH=' || log.length)
call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
call writeln(handle, 'CIDNAME=' || log.cidname)
call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
call writeln(handle, 'COMMENT=' || log.comment)
call writeln(handle, 'FILENAME=' || log.filename)
call writeln(handle, 'ALTFILENAME=' || log.altfilename)
call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
call writeln(handle, 'RETURNRETRY=' || log.returnretry)
call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
call close(handle)
address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
end; else call showDebugger('Could not update' logFile(mailbox, handle))
return
showDebugger: procedure
if arg() ~= 1 then do
say "showDebugger: ERROR"
exit 20
end
parse arg debuggerInfo
firstLine = sourceline(1)
parse var firstLine '/*' 'TITLE:' title '*/'
if showlist('p', 'AVMUSERINTERFACE') then
address 'AVMUSERINTERFACE' 'addlog' title ':' debuggerInfo
else
say title ':' debuggerInfo
return
/*-----------------------------------------------------------------------*/
/* signal processing */
arexxerror:
error:
call showDebugger("Error" rc "at line" sigl)
exit 20
break_c:
halt:
call showDebugger("Halt/Break_C at line" sigl)
exit 20
novalue:
call showDebugger("No value at line" sigl)
exit 20
syntax:
call showDebugger("Syntax error" rc "at line" sigl)
exit 20
/* TITLE: avm:rexx/stdplayvoice.avm */
stdPlayXX:
procedure
parse arg ret
rs.normal = 0
rs.keydetected = 1
rs.quietdetected = 2
rs.silencedetected = 3
rs.faxdetected = 4
rs.datadetected = 5
rs.busydetected = 8
rs.timedout = 10
rs.signaldetected = 12
rs.overflow = 14
rs.error = 16
/* CB 0000 */
select
when ret=rs.faxdetected then signal stdfax
when ret=rs.datadetected then signal stddata
when ret=rs.busydetected then signal stdbusy
when ret=rs.signaldetected then signal stdabort
when ret=rs.overflow then signal stderror
when ret=rs.error then signal stderror
otherwise nop
end
return
aapresentmenu:
/* TITLE: avm:rexx/presentmenu.avm */
procedure expose pmRetries pmTimesAround
parse arg filename, valid, retries
timesaround = retries
pmTimesAround = timesaround
pmRetries = retries
rs.normal = 0
rs.keydetected = 1
rs.quietdetected = 2
rs.silencedetected = 3
rs.faxdetected = 4
rs.datadetected = 5
rs.busydetected = 8
rs.timedout = 10
rs.signaldetected = 12
rs.overflow = 14
rs.error = 16
/* CB 0000 */
aapresentmenuloop:
'playvoice' filename
a_=rc
if 0 then nop
else if a_=4 then do;return rs.faxdetected;end
else if a_=5 then do;return rs.datadetected;end
else if a_=8 then do;return rs.busydetected;end
else if a_=12 then do;return rs.signaldetected;end
else if a_=14 then do;return rs.error;end
else if a_=16 then do;return rs.error;end
'readnkeys' '1' '5'
a_=rc
if a_=0 then value=result
if 0 then nop
else if a_=0 then signal aapresentmenuvalue
else if a_=4 then do;return rs.faxdetected;end
else if a_=5 then do;return rs.datadetected;end
else if a_=8 then do;return rs.busydetected;end
else if a_=10 then signal aapresentmenutimeout
else if a_=12 then do;return rs.signaldetected;end
else if a_=14 then do;return rs.error;end
else if a_=16 then do;return rs.error;end
return rs.error
aapresentmenutimeout:
'flushphonebuffer'
'playvoice' 'avm:voices/TimedOut'
a_=rc
if 0 then nop
else if a_=4 then do;return rs.faxdetected;end
else if a_=5 then do;return rs.datadetected;end
else if a_=8 then do;return rs.busydetected;end
else if a_=12 then do;return rs.signaldetected;end
else if a_=14 then do;return rs.error;end
else if a_=16 then do;return rs.error;end
timesaround = timesaround - 1; pmTimesAround = timesaround
if timesaround <= 0 then return rs.timedout
signal aapresentmenuloop
aapresentmenuvalue:
if pos(value, valid) = 0 then signal aainvalid
return '=' || value
aainvalid:
'flushphonebuffer'
'playvoice' 'avm:voices/BadChoice'
a_=rc
if 0 then nop
else if a_=4 then do;return rs.faxdetected;end
else if a_=5 then do;return rs.datadetected;end
else if a_=8 then do;return rs.busydetected;end
else if a_=12 then do;return rs.signaldetected;end
else if a_=14 then do;return rs.error;end
else if a_=16 then do;return rs.error;end
timesaround = timesaround - 1; pmTimesAround = timesaround
if timesaround <= 0 then return rs.timedout
signal aapresentmenuloop
stdabort:
exit
stdbusy:
exit
stderror:
exit
stdtimedout:
exit
stdfaxinstruct:
'playvoice' 'avm:voices/FaxStarting'
a_=rc
if 0 then nop
else if a_=1 then do;call checkifabort;end
else if a_=8 then signal stdbusy
else if a_=12 then signal stdabort
stdfax:
faxscript = getclip(address() || 'FAXSCRIPT')
if faxscript = '' then faxscript = 'handlefax'
if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
else address rexx faxscript address() 'anonymous'
exit
stddatainstruct:
'playvoice' 'avm:voices/DataStarting'
a_=rc
if 0 then nop
else if a_=1 then do;call checkifabort;end
else if a_=8 then signal stdbusy
else if a_=12 then signal stdabort
stddata:
datascript = getclip(address() || 'DATASCRIPT')
if datascript = '' then datascript = 'handledata'
if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
else address rexx datascript address()
exit
checkifabort:
'readnkeys' '1' '3'
a_=rc
if a_=0 then value=result
if 0 then nop
else if a_=0 then do;if value = '*' then signal stdabort;end
else if a_=8 then signal stdbusy
else if a_=12 then signal stdabort
else if a_=14 then signal stderror
else if a_=16 then signal stderror
return